const user = {}
user.userInfo = wx.getStorageSync('userInfo') || null
import { getLogin ,userLogin } from '../service/home.js'

user.getLogin = function () {
	wx.login({
		timeout: 5000,
		success(res) {
			getLogin(res.code).then((res) => {
        // 存储user的id
        wx.setStorageSync('openid', res.data.openid)
        userLogin({
          openid:res.data.openid
        }).then(res=>{

          // console.log(res);
        })
        // 向服务器发起登录的请求

			})
		},
	})
}
user.setUserInfo = function (data) {
	wx.setStorageSync('userInfo', data)
	wx.$user.userInfo = data
}
user.order = {
	buyer: 144,
	desc: '便携式等离子消毒机第1个子项目的描述',
	g_picture:
		'https://img30.360buyimg.com/cf/jfs/t1/143826/34/737/34643/5ee74e45E7c972d1c/03adc2c2e06c4eda.jpg',
	gid: 40,
	id: 11,
	limit_num: 200,
	name: '便携式等离子消毒机的第1个子项目',
	pic: '',
	price: '6841.00',
	return_time: 0,
	store_num: 1000,
}



user.add = function (){
  let count = 0
  for (let i = 9; i > 0; i--){
    count+=i
  }
  
  console.log(count);

}

export default user